package org.bookshare.document.navigation.chapters;

import org.benetech.collections.IdTree;
import org.bookshare.document.navigation.GenericNavigationElement;
import org.bookshare.document.navigation.NavigationElement;
import org.jdom.Element;

/**
 * A chapter in a document. Relevant in the context of a {@link Chapters} object, which is a collection of chapters.
 * @author Reuben Firmin
 */
public class Chapter extends GenericNavigationElement {

	private int minDistance;
	private boolean found;

	/**
	 * Constructor.
	 * @param delegate The datastructure behind the chapter.
	 */
	public Chapter(final IdTree<Element, String, String> delegate) {
		super(delegate, NavigationElementType.CHAPTER);
	}

	/**
	 * Whether the chapter has been found in one of the other Chapters sets, when comparing candidates.
	 * @return True if so
	 */
	public final boolean isFound() {
    	return found;
    }

	/**
	 * Set whether this has been found
	 * @param found True if so
	 */
	public final void setFound(final boolean found) {
    	this.found = found;
    }

	/**
	 * The closest distance, in number of elements, from this chapter to another chapter in another set of Chapters.
	 * This is used when comparing two chapters, to see how equivalent they are.
	 * @return The minimum distance.
	 */
	public final int getMinDistance() {
    	return minDistance;
    }

	/**
	 * The closest distance
	 * @param minDistance The minimum distance
	 */
	public final void setMinDistance(final int minDistance) {
    	this.minDistance = minDistance;
    }
}
